package com.aaa.gs.service;

import com.aaa.common.entity.Order;
import com.aaa.gs.mapper.ProductMapper;
import com.aaa.gs.po.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * @fileName:ProductServiceImpl
 * @description:
 * @author:忆尘
 * @createTime:2020/11/3 17:06
 * @version:1.0.0
 */

@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductMapper productMapper;

    //注入RestTemplate对象
    @Autowired
    private RestTemplate restTemplate;

    @Override
    public List<Product> selectAll() {
        return null;
    }

    @Override
    public Product selectByPrimaryKey(Long id) {
        return null;
    }

    /**
     * 远程调用
     * @return
     */
    @Override
    public List<Order> selectOrders() {
        //orderService 必须和要调用的服务的向注册中心的引用名称一致
        //order/selectAll 必须和调用服务中的方法请求的url一致
        return restTemplate.getForObject("http://orderService/order/selectAll",List.class);
    }
}
